package com.zxl.grocery.microservice.auth.server.feign;

import com.zxl.grocery.microservice.api.authority.PermissionInfo;
import com.zxl.grocery.microservice.api.user.UserInfo;
import com.zxl.grocery.microservice.auth.server.configuration.FeignConfiguration;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


/**
 * 服务与服务之间的调用
 * Created by zxl on 2017/10/13 0013.
 */
@FeignClient(value = "admin-back",configuration = FeignConfiguration.class)
public interface IUserService {

  //1、@GetMapping不支持， 2、@PathVariable得设置value 3、只要参数是复杂对象，即使指定了是GET方法，feign依然会以POST方法进行发送请求，需要用@RequestParam()
  @RequestMapping(value = "/api/user/username/{username}", method = RequestMethod.GET)
  public UserInfo getUserByUsername(@PathVariable("username") String username);

  @RequestMapping(value = "/api/user/un/{username}/permissions", method = RequestMethod.GET)
  public List<PermissionInfo> getPermissionByUsername(@PathVariable("username") String username);

  @RequestMapping(value = "/api/permissions", method = RequestMethod.GET)
  List<PermissionInfo> getAllPermissionInfo();
}
